package com.yasee.chronic.util;

import android.app.AlarmManager;
import android.content.Context;
import android.os.Build;

import zuo.biao.library.util.Log;

public class CommonUtils {

    // 需要权限：<uses-permission android:name="android.permission.SET_TIME" />
    public static void setSystemTime(long timeMillis, Context context) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            try {
                // 直接设置系统时间（单位：毫秒）
                alarmManager.setTime(timeMillis);
            } catch (SecurityException e) {
                Log.e("TimeUtils", "Permission denied: SET_TIME required.");
            }
        }
    }

}
